import { defineStore } from "../pinia";
// import { defineStore } from "pinia";
import { ref, computed } from "vue";

export const useCountStore = defineStore("countStor", {
  state: () => ({
    count: 0,
    arr: [1, 2, 3],
  }),
  getters: {
    doubleCount(state) {
      return state.count * 2;
    },
  },
  actions: {
    increment() {
      // return new Promise((resolve, reject) => {
      //   setTimeout(() => {
      //     reject(123);
      //   }, 1000);
      // });
      console.log(111);
      this.count++;
    },
  },
});

// export const useCountStore = defineStore("countStor", () => {
//   const count = ref(0);
//   const doubleCount = computed(() => count.value * 2);

//   function increment() {
//     count.value++;
//   }
//   return {
//     count,
//     increment,
//     doubleCount,
//   };
// });
